<?php

namespace addons\crontab\model;

use think\Model;

//其他入库明细
class Rdrecords08 extends Model
{
    protected $connection = "database.inc";
    protected $table = "rdrecords08";
    
    /*
     * 新增数据（表体）,返回表头ID
     *   */
    public function insertDetail($data,$irowno){
        if(!$data){
            exception('rdrecords08表体为空');
        }
        
        //表头自增ID
        if(!isset($data['ID'])){
            exception('rdrecords08表头ID为空');
        }
        
        //默认行号1开始
        $irowno++;
        
        //表体
        $model = self::create([
            'AutoID' => Crontab::getAutoIDByTname('rdrecords08'),
            'ID' => $data['ID'],//表头id
            'cInvCode'=>$data['number'],
            'iQuantity' => $data['quantity'],
            'irowno' => $irowno//1开始
        ]);
        
        //更新pda单据表，中间库表体id
        db('temporary')->where('id',$data['temporary_id'])->update([
            'mid_rdrecord_id' => $data['ID'],
            'mid_rdrecords_id' => $model->AutoID
        ]);
    }
}
